﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Pout_Porri.Screens.Interface;
using Pout_Porri.Objects;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
using Pout_Porri.Utils;
using Pout_Porri.Levels;

namespace Pout_Porri.Screens
{
    class GoldenAxeScreen : Screen, IScreen
    {
        private Level level;
        private LevelManager levelManager;
        private GameWindow gameWindow;
        private Sonic sonic;


        // Atenção: Ao término da fase, classificar a boleana abaixo chamada de levelEnd como verdadeira, assim, a função Change Level no final da classe será acionada.


        private bool levelEnd;
        public bool LevelEnd
        {
            get { return levelEnd; }
            set { LevelEnd = value; }
        }


        public GoldenAxeScreen(Texture2D background, GameWindow gameWindow)
            : base(background)
        {
            this.gameWindow = gameWindow;
        }

        public override void load(ContentManager content)
        {
            Texture2D background = content.Load<Texture2D>("Images\\Scene\\Sonic\\MapaSonic1");
            level = new Level(3, new Vector2(GameConfig.GAME_WIDTH, GameConfig.GAME_HEIGHT), content, background);
            sonic = new Sonic(content.Load<Texture2D>("Images\\Sonic\\Sonic"), new Vector2(100, 200), new Vector2(300, 200));

            level.setPlayer(sonic);
            Tileset tileset = new Tileset(143, 12, 0);
            //tileset.loadTexture("Images\\Scene\\sonicTileset", content);
            
            level.setTileset(tileset);
            
            levelManager = new LevelManager();
            levelManager.setLevel(level);
        }

        public override void update(GameTime gameTime, GameWindow Window)
        {
            levelManager.updateLevel(gameTime, Game1.keyboardState);

            Game1.camera.Update(sonic.position - Game1.camera.Position);
        }

        public override void draw(SpriteBatch spriteBatch)
        {
            levelManager.drawCurrentLevel(spriteBatch);
        }
    }
}
